home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / News / Alexandra.0.82 / Source / MatrixScroller.m < prev    next >
Encoding:
Text File  |  1996-01-30  |  1.0 KB  |  38 lines

  1.  
  2. #import <appkit/appkit.h>
  3. #import "MatrixScroller.h"
  4.  
  5. @implementation Matrix(MatrixScroller) 
  6.  
  7. - scrollCellToVisible:(int)number upperOffset:(float)up lowerOffset:(float)low
  8. {
  9.    NXRect visibleRect;
  10.    NXSize theCellSize;
  11.    NXPoint doNothingZone;
  12.  
  13.    NX_ASSERT(number>=0,"Wrong param scrolling matrix");
  14.    [self getVisibleRect:&visibleRect];
  15.    [self getCellSize:&theCellSize];
  16.  
  17.    doNothingZone.x=NX_Y(&visibleRect);
  18.    doNothingZone.y=NX_MAXY(&visibleRect);
  19.    if(low!=0.0)
  20.       doNothingZone.y-=low*theCellSize.height;
  21.    if(up!=0.0)
  22.       doNothingZone.x+=up*theCellSize.height;
  23.    if((NX_HEIGHT(&visibleRect)<=4.0*theCellSize.height)||
  24.      (number*theCellSize.height<doNothingZone.x)||
  25.      ((number+1)*theCellSize.height>doNothingZone.y)){
  26.         float new_y;
  27.         new_y=number*theCellSize.height;
  28.         new_y-=(NX_HEIGHT(&visibleRect)-theCellSize.height)/2;
  29.         if(new_y<0.0)
  30.            new_y=0.0;
  31.         NX_Y(&visibleRect)=new_y;
  32.         [self scrollRectToVisible:&visibleRect];
  33.    }
  34.    return self;
  35. }
  36.  
  37. @end
  38.